import React, { createContext, useReducer } from 'react'
import List from './List'
import InputForm from './InputForm'
import initialState from './store'
import reducer, { ActionType } from './reducer'

export const TodoContext = createContext({
  todoList: initialState,
  dispatch: (action: ActionType): void => {
    //
  },
})

const TodoReducerDemo: React.FC = () => {
  const [todoList, dispatch] = useReducer(reducer, initialState)
  return (
    <TodoContext.Provider value={{ todoList, dispatch }}>
      <p>Todo list bu useReducer</p>
      <List />
      <InputForm />
    </TodoContext.Provider>
  )
}

export default TodoReducerDemo
